package com.jash.labor.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jash.labor.context.Result;
import com.jash.labor.entity.Company;
import com.jash.labor.entity.StationFav;
import com.jash.labor.mapper.StationFavMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.sql.Date;
import java.util.HashMap;
import java.util.List;

@Service
public class StationFavService {
    @Resource
    private StationFavMapper stationFavMapper;

    public Object add(StationFav stationFav){
        stationFav.setCreatetime(new Timestamp(System.currentTimeMillis()));
       /*
       StationFav stationFav = new StationFav();
        stationFav.setId(id);
        stationFav.setStationId(stationId);
        stationFav.setLaborId(laborId);
        stationFav.setCreatetime(new Date(System.currentTimeMillis()));
        */
        stationFavMapper.insert(stationFav);
        return Result.SUCCESS;
    }
    public Object edit(StationFav stationFav){
        stationFavMapper.updateById(stationFav);
        return Result.SUCCESS;
    }

    public Object queryListPage(Integer Id,Integer pageNo,Integer pageSize) {
        //id删除后把上面的Integer Id 也删掉；
        Page<StationFav> page = new Page(pageNo,pageSize);
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("id",Id);
        //出现问题删掉上面那行；
        IPage iPage = stationFavMapper.selectPage(page,wrapper);
        return new Result<>(iPage);
    }

    public Object laborQueryStationFavList(Integer company_id,Integer pageNo,Integer pageSize) {
        Page<HashMap> page = new Page<>(pageNo,pageSize);
        IPage<HashMap> iPage = stationFavMapper.laborQueryStationFavList(page,company_id);
        return new Result<>(iPage);
    }
}
